Full source code website bán hàng thương mại điện tử gần giống shopee
468.887 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh mục trung tâm trợ giúp: <b> <a href="./?act=help_category_m"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"></font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $result = mysql_query("select cat_id from help where cat_id='".$id."'",$con);
14 if (mysql_num_rows($result)<=0) {
15 $sql = "delete from help_cat where id='".$id."'";
16 @$result = mysql_query($sql,$con);
17 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
18 else echo "<p align=center class='err'>Không thể xóa dữ liệu</font></p>";
19 } else {
20 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
21 }
22
23 break;
24 }
25 ?>
26
27 <?
28 if (isset($_POST['ButDel'])) {
29 $cnt=0;
30 foreach ($_POST['chk'] as $id)
31 {
32 @$result = mysql_query("delete from help_cat where id='".$id."'",$con);
33 if ($result) $cnt++;
34 }
35 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
36 }
37 ?>
38 <?
39 $page = $_GET["page"];
40 $p=0;
41 if ($page!='') $p=$page;
42 $where="1=1";
43 if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
44 ?>
45 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
46 <input type=hidden name="page" value="<? echo $page; ?>">
47 <?
48 function taotrang($sql,$link,$nitem,$itemcurrent)
49 { global $con;
50 $ret="";
51 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
52 $value = mysql_fetch_array($result);
53 $plus = (($value['cnt'] % $nitem)>0);
54 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
55 {
56 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
57 else $ret .= ($i+1)." ";
58 }
59 return $ret;
60 }
61 $pageindex=taotrang("select count(*) from help_cat where $where","./?act=help_category"."&page=",$MAXPAGE,$page);
62 ?>
63
64
65 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
66 <tr>
67 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
68 <td nowrap class="title"> </td>
69 <td nowrap class="title"> </td>
70 <td align="center" nowrap class="title"><b>Tên danh muc</b></td>
71 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
72 <td align="center" nowrap class="title"><b>Thu tu</b></td>
73 <td align="center" nowrap class="title"><b>Ngày</b></td>
74 </tr>
75
76 <?
77 $sql="select * from help_cat where $where order by thutu ";
78 $result=mysql_query($sql,$con);
79 $i=0;
80 while(($row=mysql_fetch_array($result)))
81 {
82 $i++;
83 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
84
85
86 ?>
87
88 <tr>
89 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
90 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
91 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
92 <a href="./?act=help_category_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Sửa</a></td>
93 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
94 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=help_category&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['id']; ?>">Xoá</a></td>
95 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
96 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['parent']; ?> </td>
97 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
98 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo date('d/m/Y',strtotime($row['date'])); ?> </td>
99 </tr>
100 <?
101 }
102 ?>
103 </table>
104 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
105 <input type="hidden" name="act" value="help_category">
106 </form>
107 <script language="JavaScript">
108 function chkallClick(o) {
109 var form = document.frmList;
110 for (var i = 0; i < form.elements.length; i++) {
111 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
112 form.elements[i].checked = document.frmList.chkall.checked;
113 }
114 }
115 }
116 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh mục trung tâm trợ giúp: <b> <a href="./?act=help_category_m"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"></font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $result = mysql_query("select cat_id from help where cat_id='".$id."'",$con);
14 if (mysql_num_rows($result)<=0) {
15 $sql = "delete from help_cat where id='".$id."'";
16 @$result = mysql_query($sql,$con);
17 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
18 else echo "<p align=center class='err'>Không thể xóa dữ liệu</font></p>";
19 } else {
20 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
21 }
22
23 break;
24 }
25 ?>
26
27 <?
28 if (isset($_POST['ButDel'])) {
29 $cnt=0;
30 foreach ($_POST['chk'] as $id)
31 {
32 @$result = mysql_query("delete from help_cat where id='".$id."'",$con);
33 if ($result) $cnt++;
34 }
35 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
36 }
37 ?>
38 <?
39 $page = $_GET["page"];
40 $p=0;
41 if ($page!='') $p=$page;
42 $where="1=1";
43 if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
44 ?>
45 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
46 <input type=hidden name="page" value="<? echo $page; ?>">
47 <?
48 function taotrang($sql,$link,$nitem,$itemcurrent)
49 { global $con;
50 $ret="";
51 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
52 $value = mysql_fetch_array($result);
53 $plus = (($value['cnt'] % $nitem)>0);
54 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
55 {
56 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
57 else $ret .= ($i+1)." ";
58 }
59 return $ret;
60 }
61 $pageindex=taotrang("select count(*) from help_cat where $where","./?act=help_category"."&page=",$MAXPAGE,$page);
62 ?>
63
64
65 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
66 <tr>
67 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
68 <td nowrap class="title"> </td>
69 <td nowrap class="title"> </td>
70 <td align="center" nowrap class="title"><b>Tên danh muc</b></td>
71 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
72 <td align="center" nowrap class="title"><b>Thu tu</b></td>
73 <td align="center" nowrap class="title"><b>Ngày</b></td>
74 </tr>
75
76 <?
77 $sql="select * from help_cat where $where order by thutu ";
78 $result=mysql_query($sql,$con);
79 $i=0;
80 while(($row=mysql_fetch_array($result)))
81 {
82 $i++;
83 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
84
85
86 ?>
87
88 <tr>
89 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
90 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
91 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
92 <a href="./?act=help_category_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Sửa</a></td>
93 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
94 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=help_category&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['id']; ?>">Xoá</a></td>
95 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
96 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['parent']; ?> </td>
97 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
98 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo date('d/m/Y',strtotime($row['date'])); ?> </td>
99 </tr>
100 <?
101 }
102 ?>
103 </table>
104 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
105 <input type="hidden" name="act" value="help_category">
106 </form>
107 <script language="JavaScript">
108 function chkallClick(o) {
109 var form = document.frmList;
110 for (var i = 0; i < form.elements.length; i++) {
111 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
112 form.elements[i].checked = document.frmList.chkall.checked;
113 }
114 }
115 }
116 </script>